package com.example.wanted.repository;

import com.example.wanted.model.Question;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Qualifier("question")
public interface QuestionRepository extends JpaRepository<Question, Long> {

    @Query("select u from question u where u.user_id = ?1")
    public Question findByUser(String user_id);

    @Query("select u from question u where u.question_id=?1")
    public Question findByQuestionID(Long question_id);

    @Query("select u from question u where u.label=?1")
    public Question findByLabel(Integer label);

    @Query("select count (question_id) from question")
    public Long findSumQuestion();

    @Query("select u from question u")
    public List<Question> getQuestions();

//    @Query("select u.comment from question u where u.id = ?1")
//    public Comment findCommentById(int id);

//    @Query("select u from user u where u.openid = ?1")
//    public User findByOpenid(String openid);
}
